/**
 * vTicker jQuery plugin
 * https://github.com/richhollis/vticker
 * Released under the MIT license
 */

(function($){var resize=0;var defaults={speed:700,pause:4000,showItems:1,mousePause:!0,height:0,animate:!0,margin:0,padding:0,startPaused:!1};var internal={moveUp:function(state,attribs){internal.animate(state,attribs,'up')},moveDown:function(state,attribs){internal.animate(state,attribs,'down')},animate:function(state,attribs,dir){var height=state.itemHeight;var options=state.options;var el=state.element;var obj=el.children('.uael-slide-main_ul');var selector=(dir==='up')?'.uael-slide-block:first':'.uael-slide-block:last';el.trigger("vticker.beforeTick");var clone=obj.children(selector).clone(!0);if(options.height>0)height=obj.children('.uael-slide-block:first').height();height+=(options.margin)+(options.padding*2);if(dir==='down')obj.css('top','-'+height+'px').prepend(clone);if(el.hasClass('uael-adjust-width')){var width_t=el.children('.uael-slide-main_ul').children('.uael-slide-block:nth-child(2)').find('.uael-slide_text').width();el.delay(options.speed/2).animate({width:width_t},options.speed/1.6)}
if(attribs&&attribs.animate){if(state.animating)return;state.animating=!0;var opts=(dir==='up')?{top:'-='+height+'px'}:{top:0};obj.animate(opts,options.speed,function(){$(obj).children(selector).remove();$(obj).css('top','0px');state.animating=!1;el.trigger("vticker.afterTick")})}else{obj.children(selector).remove();obj.css('top','0px');el.trigger("vticker.afterTick")}
if(dir==='up')clone.appendTo(obj)},nextUsePause:function(){if($(this).data('state')){var state=$(this).data('state');var options=state.options;if(state.isPaused||state.itemCount<2)return;methods.next.call(this,{animate:options.animate})}},startInterval:function(){var state=$(this).data('state');if(!state)return;var options=state.options;var initThis=this;state.intervalId=setInterval(function(){internal.nextUsePause.call(initThis)},options.pause)},stopInterval:function(){var state=$(this).data('state');if(state.intervalId)clearInterval(state.intervalId);state.intervalId=undefined},restartInterval:function(){internal.stopInterval.call(this);internal.startInterval.call(this)}};var methods={init:function(options){methods.stop.call(this);var defaultsClone=jQuery.extend({},defaults);var options=$.extend(defaultsClone,options);var el=$(this);var state={itemCount:el.children('.uael-slide-main_ul').children('.uael-slide-block').length,itemHeight:0,itemMargin:0,element:el,animating:!1,options:options,isPaused:(options.startPaused)?!0:!1,pausedByCode:!1};$(this).data('state',state);if(el.hasClass('uael-adjust-width')){var width_t=el.children('.uael-slide-main_ul').children('.uael-slide-block:nth-child(1)').find('.uael-slide_text').width()+2;el.css({overflow:'hidden',position:'relative',width:width_t}).children('.uael-slide-main_ul').css({position:'relative',margin:0,padding:0}).children('.uael-slide-block').css({margin:options.margin,padding:options.padding})}else{el.children('.uael-slide-main_ul').css({position:'relative',margin:0,padding:0}).children('.uael-slide-block').css({margin:options.margin,padding:options.padding})};if(isNaN(options.height)||options.height===0)
{el.children('.uael-slide-main_ul').children('.uael-slide-block').each(function(){var current=$(this).children('.uael-slide_text');if(current.height()>state.itemHeight)
state.itemHeight=current.height()});el.children('.uael-slide-main_ul').children('.uael-slide-block').each(function(){var current=$(this);current.height(state.itemHeight)});var box=(options.margin)+(options.padding*2);el.height(((state.itemHeight+box)*options.showItems)+options.margin)}
else{el.height(options.height)}
var initThis=this;if(!options.startPaused){internal.startInterval.call(initThis)}
if(options.mousePause)
{el.bind("mouseenter",function(){if(state.isPaused===!0)return;state.pausedByCode=!0;internal.stopInterval.call(initThis);methods.pause.call(initThis,!0)}).bind("mouseleave",function(){if(state.isPaused===!0&&!state.pausedByCode)return;state.pausedByCode=!1;methods.pause.call(initThis,!1);internal.startInterval.call(initThis)})}},pause:function(pauseState){var state=$(this).data('state');if(!state)return undefined;if(state.itemCount<2)return!1;state.isPaused=pauseState;var el=state.element;if(pauseState){$(this).addClass('paused');el.trigger("vticker.pause")}
else{$(this).removeClass('paused');el.trigger("vticker.resume")}},next:function(attribs){var state=$(this).data('state');if(!state)return undefined;if(state.animating||state.itemCount<2)return!1;internal.restartInterval.call(this);internal.moveUp(state,attribs)},prev:function(attribs){var state=$(this).data('state');if(!state)return undefined;if(state.animating||state.itemCount<2)return!1;internal.restartInterval.call(this);internal.moveDown(state,attribs)},stop:function(){var state=$(this).data('state');if(!state)return undefined;internal.stopInterval.call(this)},remove:function(){var state=$(this).data('state');if(!state)return undefined;internal.stopInterval.call(this);var el=state.element;el.unbind();el.remove()},};$.fn.vTicker=function(method){if(methods[method]){return methods[method].apply(this,Array.prototype.slice.call(arguments,1))}else if(typeof method==='object'||!method){return methods.init.apply(this,arguments)}else{$.error('Method '+method+' does not exist on jQuery.vTicker')}}})(jQuery)